<template>
  <div class="bg-gray-50 min-h-screen">
    <!-- 顶部导航栏 -->
    <header class="bg-white border-b border-gray-200 sticky top-0 z-50">
      <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div class="flex justify-between items-center h-16">
          <!-- Logo和身份标识 -->
          <div class="flex items-center gap-3">
            <div class="w-10 h-10 bg-blue-500 rounded-full overflow-hidden">
                <img src="../../../头像.jpg" alt="头像" class="w-full h-full object-cover" />
              </div>
            <span class="text-xl font-semibold text-gray-900">校园快递代拿</span>
            <span class="px-3 py-1 bg-blue-50 text-blue-600 text-sm rounded-full">代拿员</span>
          </div>

          <!-- 右侧按钮 -->
          <div class="flex items-center gap-4">
            <button class="flex items-center gap-2 text-gray-600 hover:text-gray-900" @click="$router.push('/')">
              <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/>
              </svg>
              首页
            </button>
            <button class="flex items-center gap-2 text-gray-600 hover:text-gray-900" @click="logout">
              <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"/>
              </svg>
              退出
            </button>
          </div>
        </div>
      </div>
    </header>

    <!-- 标签页导航 -->
    <div class="bg-white border-b border-gray-200">
      <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <nav class="flex gap-8">
          <button class="py-4 text-gray-600 hover:text-blue-600 border-b-2 border-transparent hover:border-blue-600" @click="$router.push('/courier/hall')">接单大厅</button>
          <button class="py-4 text-gray-600 hover:text-blue-600 border-b-2 border-transparent hover:border-blue-600" @click="$router.push('/courier/orders')">我的订单</button>
          <button class="py-4 text-blue-600 border-b-2 border-blue-600 font-medium">我的主页</button>
        </nav>
      </div>
    </div>

    <!-- 主要内容区域 -->
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
      <div class="flex gap-6">
        <!-- 左侧边栏 -->
        <aside class="w-80 flex-shrink-0">
          <!-- 用户信息卡片 -->
          <div class="bg-white rounded-2xl shadow-sm p-6 mb-6">
            <div class="flex flex-col items-center">
              <img src="https://hebbkx1anhila5yf.public.blob.vercel-storage.com/1590761a7c9638891d357d5bc43289d7-4G10LVqa0kzCfvASn5aCd7e04aK78M.png" alt="用户头像" class="w-24 h-24 rounded-full object-cover mb-4">
              <h2 class="text-xl font-semibold text-gray-900 mb-2">李同学</h2>
              <span class="px-3 py-1 bg-blue-50 text-blue-600 text-sm rounded-full mb-6">代拿员</span>
              <div class="flex gap-8 w-full justify-center">
                <div class="text-center"><div class="text-2xl font-bold text-gray-900">42</div><div class="text-sm text-gray-500 mt-1">已完成</div></div>
                <div class="text-center"><div class="text-2xl font-bold text-gray-900">4.9</div><div class="text-sm text-gray-500 mt-1">平均分</div></div>
                <div class="text-center"><div class="text-2xl font-bold text-gray-900">5</div><div class="text-sm text-gray-500 mt-1">进行中</div></div>
              </div>
            </div>
          </div>

          <!-- 导航菜单 -->
          <nav class="bg-white rounded-2xl shadow-sm overflow-hidden">
            <button class="flex items-center gap-3 px-6 py-4 bg-blue-50 text-blue-600 border-l-4 border-blue-600 w-full text-left">
              <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/></svg>
              个人信息
            </button>
            <button class="flex items-center gap-3 px-6 py-4 text-gray-600 hover:bg-gray-50 border-l-4 border-transparent w-full text-left" @click="$router.push('/courier/data')">
              <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/></svg>
              服务数据
            </button>
            <button class="flex items-center gap-3 px-6 py-4 text-gray-600 hover:bg-gray-50 border-l-4 border-transparent w-full text-left" @click="$router.push('/courier/settings')">
              <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/></svg>
              接单设置
            </button>
            <button class="flex items-center gap-3 px-6 py-4 text-gray-600 hover:bg-gray-50 border-l-4 border-transparent w-full text-left" @click="$router.push('/courier/wallet')">
              <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"/></svg>
              我的钱包
            </button>
            <button class="flex items-center gap-3 px-6 py-4 text-gray-600 hover:bg-gray-50 border-l-4 border-transparent w-full text-left" @click="$router.push('/courier/security')">
              <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"/></svg>
              账号安全
            </button>
            <button class="flex items-center gap-3 px-6 py-4 text-gray-600 hover:bg-gray-50 border-l-4 border-transparent w-full text-left" @click="$router.push('/courier/notify')">
              <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"/></svg>
              通知设置
            </button>
            <button class="flex items-center gap-3 px-6 py-4 text-gray-600 hover:bg-gray-50 border-l-4 border-transparent w-full text-left" @click="$router.push('/courier/help')">
              <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
              帮助与反馈
            </button>
            <button class="flex items-center gap-3 px-6 py-4 text-red-600 hover:bg-red-50 border-l-4 border-transparent w-full text-left" @click="logout">
              <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"/></svg>
              退出登录
            </button>
          </nav>
        </aside>

        <!-- 右侧主内容区 -->
        <main class="flex-1">
          <div class="bg-white rounded-2xl shadow-sm p-8">
            <!-- 标题 -->
            <div class="mb-8">
              <h1 class="text-2xl font-bold text-gray-900 mb-2">个人信息</h1>
              <p class="text-gray-500">完善个人信息，提升账号安全性和可信度</p>
            </div>

            <!-- 基本信息 -->
            <div class="mb-8">
              <h2 class="text-lg font-semibold text-gray-900 mb-6">基本信息</h2>
              <div class="grid grid-cols-2 gap-6">
                <div>
                  <label class="block text-sm font-medium text-gray-700 mb-2">姓名</label>
                  <input v-model="userInfo.name" :disabled="!isEditing" type="text" value="李同学" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" :class="{'bg-gray-50': !isEditing}" />
                </div>
                <div>
                  <label class="block text-sm font-medium text-gray-700 mb-2">学号</label>
                  <input v-model="userInfo.studentId" :disabled="!isEditing" type="text" value="2021004567" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" :class="{'bg-gray-50': !isEditing}" />
                </div>
                <div>
                  <label class="block text-sm font-medium text-gray-700 mb-2">学院</label>
                  <input v-model="userInfo.college" :disabled="!isEditing" type="text" value="机械工程学院" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" :class="{'bg-gray-50': !isEditing}" />
                </div>
                <div>
                  <label class="block text-sm font-medium text-gray-700 mb-2">专业</label>
                  <input v-model="userInfo.major" :disabled="!isEditing" type="text" value="机械设计制造及其自动化" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" :class="{'bg-gray-50': !isEditing}" />
                </div>
              </div>
            </div>

            <!-- 联系方式 -->
            <div class="mb-8">
              <h2 class="text-lg font-semibold text-gray-900 mb-6">联系方式</h2>
              <div class="grid grid-cols-2 gap-6">
                <div>
                  <label class="block text-sm font-medium text-gray-700 mb-2">手机号</label>
                  <input type="text" value="138****5678" class="w-full px-4 py-3 border border-gray-300 rounded-lg bg-gray-50 text-gray-500" disabled />
                </div>
                <div>
                  <label class="block text-sm font-medium text-gray-700 mb-2">邮箱</label>
                  <input type="email" value="li***@example.com" class="w-full px-4 py-3 border border-gray-300 rounded-lg bg-gray-50 text-gray-500" disabled />
                </div>
              </div>
            </div>

            <!-- 代拿服务信息 -->
            <div class="mb-8">
              <h2 class="text-lg font-semibold text-gray-900 mb-6">代拿服务信息</h2>
              <div class="grid grid-cols-2 gap-6">
                <div>
                  <label class="block text-sm font-medium text-gray-700 mb-2">服务范围</label>
                  <input v-model="userInfo.serviceRange" :disabled="!isEditing" type="text" value="全校范围内" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" :class="{'bg-gray-50': !isEditing}" />
                </div>
                <div>
                  <label class="block text-sm font-medium text-gray-700 mb-2">常接单时间</label>
                  <input v-model="userInfo.serviceTime" :disabled="!isEditing" type="text" value="12:00-14:00, 17:00-21:00" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" :class="{'bg-gray-50': !isEditing}" />
                </div>
              </div>
            </div>

            <!-- 身份认证状态 -->
            <div class="mb-8">
              <h2 class="text-lg font-semibold text-gray-900 mb-6">身份认证状态</h2>
              <div class="flex items-center gap-2 text-green-600">
                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
                </svg>
                <span class="font-medium">已认证</span>
              </div>
            </div>

            <!-- 操作按钮 -->
            <div class="flex justify-end gap-4 pt-6 border-t border-gray-200">
              <button v-if="isEditing" @click="cancelEdit" class="px-6 py-3 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition-colors">取消</button>
              <button v-if="!isEditing" @click="isEditing = true" class="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors">编辑信息</button>
              <button v-if="isEditing" @click="saveEdit" class="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors">保存修改</button>
            </div>
          </div>
        </main>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CourierProfile',
  data() {
    return {
      isEditing: false,
      userInfo: {
        name: '李同学',
        studentId: '2021004567',
        college: '机械工程学院',
        major: '机械设计制造及其自动化',
        serviceRange: '全校范围内',
        serviceTime: '12:00-14:00, 17:00-21:00'
      },
      originalUserInfo: {}
    }
  },
  methods: {
    logout() {
      localStorage.removeItem('userToken')
      this.$router.push('/login')
    },
    cancelEdit() {
      this.isEditing = false
      this.userInfo = { ...this.originalUserInfo }
    },
    saveEdit() {
      this.originalUserInfo = { ...this.userInfo }
      this.isEditing = false
      alert('信息保存成功！')
    }
  },
  mounted() {
    this.originalUserInfo = { ...this.userInfo }
  }
}
</script>

